using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Smo = Microsoft.SqlServer.Management.Smo;

/// <summary>
/// Summary description for CurrentServerWebPart
/// </summary>
namespace SqlWebAdmin.CSharp.Controls
{
    public abstract class CurrentServerWebPart : WebPart
    {
        public CurrentServerWebPart()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        protected override void RenderContents(HtmlTextWriter writer)
        {
            try
            {
                System.IO.StringWriter sw = new System.IO.StringWriter();

                HtmlTextWriter contentWriter = new HtmlTextWriter(sw);

				Smo.Server server = SmoHelper.GetServer();
                if (server != null)
                {

                    RenderWebPart(server, contentWriter);

                    writer.Write(sw.ToString());
                }                
            }
            catch
            {
                writer.WriteLine( Resources.Errors.WebPartContentFailure );
            }
        }

        abstract protected void RenderWebPart(Smo.Server server, HtmlTextWriter writer);

    }
}